package com.persondemo.videoappliction.ui.vip.presenter;

import com.persondemo.videoappliction.bean.UseInfoBean;
import com.persondemo.videoappliction.net.BaseApi;
import com.persondemo.videoappliction.net.BaseObserver;
import com.persondemo.videoappliction.net.RxSchedulers;
import com.persondemo.videoappliction.ui.base.BasePresenter;
import com.persondemo.videoappliction.ui.vip.contract.MeContract;

import javax.inject.Inject;

/**
 * Created by Administrator on 2018/4/25.
 */

public class MePresenter  extends BasePresenter<MeContract.View> implements MeContract.Presenter {
    BaseApi baseApi;

    @Inject
    public MePresenter(BaseApi baseApi) {
        this.baseApi = baseApi;
    }
    @Override
    public void info(String device) {
        baseApi.geinfo(device)
                .compose(RxSchedulers.applySchedulers())
                .compose(mView.bindToLife())
                .subscribe(new BaseObserver<UseInfoBean>() {
                    @Override
                    public void onSuccess(UseInfoBean useInfoBean) {
                        mView.getinfo(useInfoBean);
                    }

                    @Override
                    public void onFail(Throwable e) {
                        mView.showFaild();
                    }
                });
    }
}
